import itertools
import random

from setuptools.namespaces import flatten

print(list(itertools.takewhile(lambda n: n < 3, itertools.count(1, .2))))
# for n in itertools.filterfalse(lambda m: m % 2 == 0, itertools.count()):
#     print(n)


ls = [random.randrange(1, 100) for n in range(10)]
def generator_function_outside():
    for n in ls:
        yield n


for i in generator_function_outside():
    for j in generator_function_outside():
        print(i, j)  # 相同


def generator_function_inside():
    ls_inside = [random.randrange(1, 100) for n in range(10)]
    for n in ls_inside:
        yield n


for i in generator_function_inside():
    for j in generator_function_inside():
        print(i, j)  # 不同


gen_expr = (random.randrange(1, 100) for n in range(10))
for i in gen_expr:
    for j in gen_expr:
        print(i, j)  # 不同


ls_tuple  = [(random.randrange(1, 100), hex(random.randrange(1, 100))) for n in range(10)]
print(ls_tuple)
flattened_ls = itertools.chain.from_iterable(ls_tuple)
for elem in flattened_ls:
    print(elem)
